using Microsoft.AspNetCore.Mvc; 
using System.Web; 

namespace WebApi8.Controllers
{
    [ApiController]
    [Route("[controller]")]
    public class OfficePreviewController : ControllerBase
    { 
        private readonly ILogger<WeatherForecastController> _logger;
        private readonly string officeliveUrl = "https://view.officeapps.live.com/op/view.aspx?src={0}";
        public OfficePreviewController(ILogger<WeatherForecastController> logger)
        {
            _logger = logger;
        }

        [HttpGet]
        public string Demo(string url)
        { 
            string encodedUrl = HttpUtility.UrlEncode(url); 
            var previewUrl = string.Format(officeliveUrl, encodedUrl); 
            return previewUrl;
        }

         
    }
}
